package Work0603;

import java.awt.List;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

/**
 * 6：把 1-10000内的所有质数 写入一个data.txt中，10个一行
 * 
 * @author Y
 *
 */
public class PrimeWrite {

	public static void main(String[] args) throws IOException {

		File w = new File("C:\\Users\\Y\\Desktop\\北大青鸟课件\\北大青鸟作业\\data.txt");
		FileWriter e = new FileWriter(w);
		boolean q = true;
		int num = 0;
		for (int a = 2; a <= 10000; a++) {
			for (int b = 2; b * b <= a; b++) {
				if (a % b == 0) {
					q = false;
				}
			}
			if (q == true) {
				num++;
				System.out.println(a);
				e.write(String.valueOf(a) + "\t");
				if (num % 10 == 0) {
					e.write("\r\n");
				}
			}
			q = true;
		}
		e.close();

	}

}
